﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Reflection;

namespace AlbumDesigner.Helpers
{
       static public class FixAppDomainRestart
       {
           static public void FixAppDomainRestartWhenTouchingFiles()
           {
               PropertyInfo p = typeof(System.Web.HttpRuntime).GetProperty("FileChangesMonitor", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static);
               object o = p.GetValue(null, null);
               FieldInfo f = o.GetType().GetField("_dirMonSubdirs", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.IgnoreCase);
               object monitor = f.GetValue(o);
               MethodInfo m = monitor.GetType().GetMethod("StopMonitoring", BindingFlags.Instance | BindingFlags.NonPublic);
               m.Invoke(monitor, new object[] { });
           }
       }
}